<template>
  <div class="app-container calendar-list-container"> 
    <!-- 收入列表 -->
    <div class="filter-container">
      {{$t('recharge.Phone_number')}}：
      <el-input clearable v-model="listQuery.usersPhone" style="width: 200px;margin-right:20px;margin-top:8px" :placeholder="$t('recharge.Phone_number')" >
      </el-input>
      <el-date-picker
        v-model="listQuery.date"
        :start-placeholder="$t('recharge.start_date')"
        :end-placeholder="$t('recharge.End_date')"
        type="datetimerange"
        :placeholder="$t('recharge.Select_date')"
        value-format="timestamp"
        style="margin-right:20px;">
      </el-date-picker>
      <el-button type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{$t('recharge.Find')}}</el-button>
    </div>
    <!-- 收入列表表格 -->
    <el-table
      :data="income"
      border
      v-loading='loading.income'
      style="width: 100%">
      <el-table-column prop="index" :label="$t('recharge.Number')"> </el-table-column>
      <el-table-column prop="paymentSn" :label="$t('recharge.Top_up_number')"> </el-table-column>
      <el-table-column prop="usersPhone" :label="$t('recharge.Phone_number')"> </el-table-column>
      <el-table-column prop="nickName" :label="$t('recharge.User_name')"> </el-table-column>
      <el-table-column prop="payType" :label="$t('recharge.Payment_type')">
        <template slot-scope="scope">
          <!-- 1.余额 2.微信App 3微信公众号 4.信用卡 -->
          <!-- {{scope.row.payType == 1?'余额':scope.row.payType == 2?'微信APP':scope.row.payType == 3?'微信公众号':'信用卡'}} -->
          {{scope.row.payType == 1?$t('recharge.Balance')+'':scope.row.payType == 2?$t('recharge.Wechat_App')+'':scope.row.payType == 3?$t('recharge.WeChat_public_number')+'':$t('recharge.Credit_Card')+''}}
        </template>
      </el-table-column>
      <el-table-column prop="revenueAmount" :label="$t('recharge.Top_up_amount')"> </el-table-column>
      <el-table-column prop="ctime" :label="$t('recharge.Top_up_time')"> 
        <template slot-scope="scope">
          <span v-if="scope.row.ctime">{{scope.row.ctime}}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- pagination 分页 -->
    <div class="pagination-container">
      <el-pagination 
        background 
        @size-change="handleSizeChange" 
        @current-change="handleCurrentChange" 
        :current-page="listQuery.pageNo" 
        :page-sizes="[10, 20, 30, 40]" 
        :page-size="listQuery.pageSize" 
        layout="total, sizes, prev, pager, next, jumper" 
        :total="total1">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { getFinanceRechargeListByPageCondition} from '@/api/topUp'
export default {
  name: 'topUp_list',
  data() {
    return {
      total1: 0,
      income: [],
      listQuery:{
        pageNo: 1,
        pageSize: 10,
        usersPhone: '',
        date:'',
      },
      dialog: {
          add: false
      },
      loading: {
        income: false,
        withdraw: false,
        reject:false
      },
    }
  },
  methods: {
    //获取充值列表
    async getList(){
      this.loading.income=true
      const { data} = await  getFinanceRechargeListByPageCondition(this.filters)
      this.income = data.records.map((item,index)=>({
        index:index+1,
        ...item
      }))
      this.total1 = data.total
      this.loading.income = false
    },
    handleFilter() {
      if(!this.listQuery.date) {
        this.listQuery.date = ''
      }
      this.listQuery.pageNo = 1
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.pageNo = val
      this.getList()
    },
  },
  computed: {
    filters() {
      return {
        pageNo: this.listQuery.pageNo,
        pageSize: this.listQuery.pageSize,
        usersPhone: this.listQuery.usersPhone,
        startTime:this.listQuery.date[0],
        endTime:this.listQuery.date[1],
      }
    },
  },
  created() {
    this.getList();
  }
}
</script>

<style lang='scss' scoped>
.cell {
  a {
    color: #409eff;
  }
}
.card-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
.el-card /deep/ .el-card__header{
    border-bottom: none
}  

</style>
